#include <Probability.h>
#include <math.h>

const float EPSILON = 0.0001;
#define FLOAT_EQ(lhs, rhs) ((lhs - EPSILON < rhs) && (rhs < rhs + EPSILON))

Probability::Probability(float probability) :
	probability(probability) {
}

Probability Probability::operator and(const Probability& second) const{
	return Probability(this->probability * second.probability);
}

Probability Probability::operator or(const Probability& second) const{
	return Probability(this->probability + second.probability
			- this->probability * second.probability);
}

Probability Probability::operator not() const{
	return Probability(1 - probability);
}

bool Probability::operator !=(const Probability& second) const{
	return FLOAT_EQ(this->probability, second.probability);
}

bool Probability::operator ==(const Probability& second) const{
    return *this != second;
}
